package com.jobguard.controller.exception;

import com.aliyun.tea.ValidateException;
import com.jobguard.entity.RestBean;
import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * function:
 * author: xxxxsl
 * date: 2024/12/4 19:11
 */
@RestControllerAdvice
@Slf4j
public class ValidationController {

    @ExceptionHandler(ConstraintViolationException.class)
    public RestBean<Void> validateException(ConstraintViolationException exception) {
        log.warn("Resolve [{}: {}]", exception.getClass().getName(), exception.getMessage());
        return RestBean.failure(400, "请求参数有误");
    }
}
